﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Models;
using BLL;

namespace Workflow
{
    public partial class Create : System.Web.UI.Page
    {
        public List<WorkflowStatus> resultList = new List<WorkflowStatus>();
        private WorkflowManager objWorkflowManager = new WorkflowManager();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.IsAuthenticated)
            {
                var statusDefine = Convert.ToInt32(Request.QueryString["statusDefine"].ToString());
                //if (statusDefine != 0)
                //{
                //    this.button1.Visible = false;
                //}
                //else
                //{
                //    this.button1.Visible = true;
                //}
                if(statusDefine==0)
                {
                    divSend.Style.Remove("display");
                    iframe.Style.Remove("display");
                }
                resultList = objWorkflowManager.GetWorkflowStatus(Session["FullName"].ToString(), statusDefine);
                if (statusDefine == 1)
                {
                    resultList.AddRange(objWorkflowManager.GetWorkflowStatus(Session["FullName"].ToString(), -1));
                    
                }
                for (int i = resultList.Count-1; i >= 0; i--)
                {
                    if (resultList[i].StatusDefine == -1)
                    {
                        resultList[i].PauseName = objWorkflowManager.GetPauseName(resultList[i].WorkParentId);
                    }
                    if (resultList[i].WorkMouldId == 3)
                    {
                        resultList.Remove(resultList[i]);
                    }
                }
            }
        }
    }
   
}